home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
051-075
/
disk_055
/
csh
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
2KB
|
127 lines
/*
* MAIN.C
*
* Matthew Dillon, 24 Feb 1986
* (c)1986 Matthew Dillon 9 October 1986
*
* version 2.05M (Manx Version and Additions) by Steve Drew 20-Jan-87
*
*/
#include "shell.h"
void cleanupconsole(), initconsole();
extern char *btocstr();
extern struct FileLock *Clock;
char Inline[256];
char stdout_buff[STDBUF];
main(argc, argv)
register char *argv[];
{
char *rawgets();
char *prompt;
register int i;
extern int Enable_Abort;
init_vars();
init();
seterr();
do_cd(NULL, -1);
Enable_Abort = 0;
for (i = 1; i < argc; ++i) {
if (argv[i][0] == '-' && argv[i][1] == 'c') {
Inline[0] = ' ';
Inline[1] = '\000';
while (++i < argc) {
strcat(Inline,argv[i]);
strcat(Inline," ");
}
exec_command(Inline);
main_exit(0);
}
strcpy (Inline, "source ");
strcat (Inline, argv[i]);
av[1] = argv[i];
do_source (Inline);
}
for (;;) {
if ((prompt = get_var (LEVEL_SET, V_PROMPT)) == NULL)
prompt = "$ ";
if (breakcheck()) {
while (WaitForChar(Input(), 1L))
gets(Inline);
}
if (Quit || !rawgets(Inline, prompt))
main_exit(0);
breakreset();
if (*Inline)
exec_command(Inline);
}
}
init_vars()
{
if (IsInteractive(Input()))
set_var (LEVEL_SET, V_PROMPT, "$ ");
else
set_var (LEVEL_SET, V_PROMPT, "");
set_var (LEVEL_SET, V_HIST, "20");
set_var (LEVEL_SET, V_LASTERR, "0");
set_var (LEVEL_SET, V_PATH, "ram:,ram:c/,c:,df1:c/,df0:c/");
}
init()
{
static char pipe1[32], pipe2[32];
initconsole();
stdout->_buff = stdout_buff;
stdout->_buflen = STDBUF;
Myprocess = (struct Process *)FindTask(0L);
Uniq = (long)Myprocess;
Pipe1 = pipe1;
Pipe2 = pipe2;
sprintf (pipe1, "ram:pipe1_%ld", Uniq);
sprintf (pipe2, "ram:pipe2_%ld", Uniq);
}
main_exit(n)
{
cleanupconsole(0);
exit (n);
}
breakcheck()
{
if (SetSignal(0L,0L) & SIGBREAKF_CTRL_C)
return (1);
else
return (0);
}
breakreset()
{
SetSignal(0L, SIGBREAKF_CTRL_C);
}
/* this routine causes manx to use this Chk_Abort() rather than it's own */
/* otherwise it resets our ^C when doing any I/O (even when Enable_Abort */
/* is zero). Since we want to check for our own ^C's */
Chk_Abort()
{
return(0);
}